package opertion;

import book.Book;
import book.BookList;

import java.util.Scanner;
//这里是通过书名进行找书
public class FindOpertion implements IOperation {
    @Override
    public void work(BookList bookList) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要查找的书名");
        String name = sc.nextLine();
//        System.out.println("请输入你要查找的作者");
//        String author = sc.nextLine();
//        System.out.println("请输入你要查找书的类型");
//        String type = sc.nextLine();
//        System.out.println("请输入你要查找书的价格");
//        int price = sc.nextInt();
//        Book book = new Book(name, author, type, price);
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            if (bookList.getBooks()[i].getName().equals(name)) {
                System.out.println(bookList.getBooks()[i].toString());
                return;
            }
        }
        System.out.println("没有该书");
    }
}
